﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Shop.Business.Domain.Orders.Logic
{
    public abstract class BaseOrderItemOperation : IOperation
    {
        protected OrderItem orderItem;


        public OrderItem OrderItemObject
        {
            get { return orderItem; }
            set { orderItem = value; }
        }

        public virtual bool IsAllowed()
        {
            // TODO assigns logic here!
            return IsAllowedModify();
        }

        public abstract void Execute(OrderController.OperationContext context);


        #region IOperation Members

        public abstract IRestriction GetRestriction();


        #endregion

        protected bool IsAllowedModify()
        {
            return orderItem.Order.OrderStatus == OrderStatus.Draft || orderItem.Order.OrderStatus == OrderStatus.Current;
        }

    }
}
